package mhe.mgt.service;

import java.util.List;

import mhe.mgt.model.MchMachine;

@SuppressWarnings("unchecked")
public class MachineServiceImpl extends GeneralServiceImpl<MchMachine> implements MachineService {

	@Override
	public Class<MchMachine> getEntityClass() {
		return MchMachine.class;
	}

	@Override
	public MchMachine[] listBySystemId(long systemId) {
		List<MchMachine> list = (List<MchMachine>) executeQuery("from MchMachine where systemId=:value1", new Object[]{systemId}, -1, -1);
		return list.toArray(new MchMachine[list.size()]);
	}
	
	@Override
	public void delete(MchMachine entity) {
		// delete all machine parts of this machine
		String hql = "delete from MCHMACHINEPART where machine_Id=:param0";
		executeSQLQuery(hql, new Object[]{entity.getId()});
		super.delete(entity);
	}
}
